package edu.lingnan.lmlibrary.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import edu.lingnan.lmlibrary.common.JSONResult;
import edu.lingnan.lmlibrary.entity.Floor;
import edu.lingnan.lmlibrary.mapper.FloorMapper;
import edu.lingnan.lmlibrary.service.FloorService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 张晓航
 * @since 2022-02-26
 */
@Service
public class FloorServiceImpl extends ServiceImpl<FloorMapper, Floor> implements FloorService {

    @Autowired(required = false)
    private FloorMapper floorMapper;

    @Override
    public JSONResult<List<Floor>> getFloorsInfo() {
        QueryWrapper<Floor> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("f_status","1");
        List<Floor> floors = floorMapper.selectList(queryWrapper);
        if(floors.size() != 0)
        {
            return new JSONResult<List<Floor>>(200,"操作成功",floors);
        }

        return new JSONResult<List<Floor>>(201,"操作失败,该时间段不可预约或者楼层暂时不可用",null);
    }
}
